package com.hsxc.cdz.monitor.bean.server.v1_33;

import com.hsxc.cdz.base.util.BytesUtil;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.util.ReferenceCountUtil;

public class ReserveSerMsg extends ServerMessage {
	
	public static final int length = 13;
	private int chargePort;
	private String cardNum;
	private int duration;
	
	
	public int getDoration() {
		return duration;
	}
	public void setDoration(int duration) {
		this.duration = duration;
	}
	public int getChargePort() {
		return chargePort;
	}
	public void setChargePort(int chargePort) {
		this.chargePort = chargePort;
	}
	public String getCardNum() {
		return cardNum;
	}
	public void setCardNum(String cardNum) {
		this.cardNum = cardNum;
	}

	@Override
	public byte[] getBytesFromMessage() {
		ByteBuf bytes = Unpooled.buffer(length);
		byte[] result;
		byte[] temp;
		//写出端口号
		temp  = BytesUtil.intToBytesSeq(this.getChargePort(), 1);
		bytes.writeBytes(temp);
		//写出用户卡号
		temp  = BytesUtil.strToBcdBytes(this.getCardNum(), 10);
		bytes.writeBytes(temp);
		//写出预约时长
		temp = BytesUtil.intToBytesDesc(this.getDoration(), 2);
		bytes.writeBytes(temp);
		
		result = new byte[bytes.readableBytes()];
		bytes.readBytes(result);
		ReferenceCountUtil.release(bytes);
		return result;
	}

}
